import { IPSDEField } from '../defield/ipsdefield';
import { IPSLinkDEField } from '../defield/ipslink-defield';
import { IPSOne2ManyDataDEField } from '../defield/ipsone2-many-data-defield';
import { IPSPickupDEField } from '../defield/ipspickup-defield';
import { IPSDER1N } from './ipsder1-n';
import { IPSDER1NDEFieldMap } from './ipsder1-ndefield-map';
import { PSDERBaseImpl } from './psderbase-impl';
import { IPSDEDataSet } from '../ds/ipsdedata-set';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDER1NImpl extends PSDERBaseImpl implements IPSDER1N {
  get cloneOrder(): number {
    return this.M.cloneOrder != null ? this.M.cloneOrder : -1;
  }

  get customExportOrder(): number {
    return this.M.customExportOrder != null ? this.M.customExportOrder : -1;
  }

  get customExportOrder2(): number {
    return this.M.customExportOrder2 != null ? this.M.customExportOrder2 : -1;
  }

  protected ermajorpsdef: IPSDEField | null = null;

  getERMajorPSDEF(): IPSDEField | null {
    if (this.ermajorpsdef != null) return this.ermajorpsdef;
    const value = this.M.getERMajorPSDEF;
    if (value == null) {
      return null;
    }
    this.ermajorpsdef = this.getMajorPSDataEntityMust().findPSDEField(value);
    return this.ermajorpsdef;
  }

  get eRMajorPSDEF(): IPSDEField | null {
    return this.getERMajorPSDEF();
  }

  getERMajorPSDEFMust(): IPSDEField {
    const value = this.getERMajorPSDEF();
    if (value == null) {
      throw new Error('未指定附加约束主属性');
    }
    return value;
  }

  protected erminorpsdef: IPSDEField | null = null;

  getERMinorPSDEF(): IPSDEField | null {
    if (this.erminorpsdef != null) return this.erminorpsdef;
    const value = this.M.getERMinorPSDEF;
    if (value == null) {
      return null;
    }
    this.erminorpsdef = this.getMinorPSDataEntityMust().findPSDEField(value);
    return this.erminorpsdef;
  }

  get eRMinorPSDEF(): IPSDEField | null {
    return this.getERMinorPSDEF();
  }

  getERMinorPSDEFMust(): IPSDEField {
    const value = this.getERMinorPSDEF();
    if (value == null) {
      throw new Error('未指定附加约束从属性');
    }
    return value;
  }

  get exportMajorModel(): 1 {
    return this.M.exportMajorModel != null ? this.M.exportMajorModel : -1;
  }

  get fKeyName(): string {
    return this.M.fKeyName;
  }

  protected majorppsder1n: IPSDER1N | null = null;

  getMajorPPSDER1N(): IPSDER1N | null {
    if (this.majorppsder1n != null) return this.majorppsder1n;
    const value = this.M.getMajorPPSDER1N;
    if (value == null) {
      return null;
    }
    this.majorppsder1n = this.getPSModel4('dataentity.der.IPSDER1N', value, 'getMajorPPSDER1N') as IPSDER1N;
    return this.majorppsder1n;
  }

  get majorPPSDER1N(): IPSDER1N | null {
    return this.getMajorPPSDER1N();
  }

  getMajorPPSDER1NMust(): IPSDER1N {
    const value = this.getMajorPPSDER1N();
    if (value == null) {
      throw new Error('未指定主实体父关系');
    }
    return value;
  }

  get masterOrder(): number {
    return this.M.masterOrder;
  }

  get masterRS(): 1 | 2 | 4 | 8 | 16 {
    return this.M.masterRS;
  }

  protected minorppsder1n: IPSDER1N | null = null;

  getMinorPPSDER1N(): IPSDER1N | null {
    if (this.minorppsder1n != null) return this.minorppsder1n;
    const value = this.M.getMinorPPSDER1N;
    if (value == null) {
      return null;
    }
    this.minorppsder1n = this.getPSModel4('dataentity.der.IPSDER1N', value, 'getMinorPPSDER1N') as IPSDER1N;
    return this.minorppsder1n;
  }

  get minorPPSDER1N(): IPSDER1N | null {
    return this.getMinorPPSDER1N();
  }

  getMinorPPSDER1NMust(): IPSDER1N {
    const value = this.getMinorPPSDER1N();
    if (value == null) {
      throw new Error('未指定从实体父关系');
    }
    return value;
  }

  protected nestedpsdedataset: IPSDEDataSet | null = null;

  getNestedPSDEDataSet(): IPSDEDataSet | null {
    if (this.nestedpsdedataset != null) return this.nestedpsdedataset;
    const value = this.M.getNestedPSDEDataSet;
    if (value == null) {
      return null;
    }
    this.nestedpsdedataset = this.getMinorPSDataEntityMust().findPSDEDataSet(value);
    return this.nestedpsdedataset;
  }

  get nestedPSDEDataSet(): IPSDEDataSet | null {
    return this.getNestedPSDEDataSet();
  }

  getNestedPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getNestedPSDEDataSet();
    if (value == null) {
      throw new Error('未指定嵌套成员数据集对象');
    }
    return value;
  }

  protected psder1ndefieldmaps: IPSDER1NDEFieldMap[] | null = null;

  getPSDER1NDEFieldMaps(): IPSDER1NDEFieldMap[] | null {
    if (this.psder1ndefieldmaps == null) {
      this.psder1ndefieldmaps = this.fillChildListModel(this.M.getPSDER1NDEFieldMaps, 'dataentity.der.IPSDER1NDEFieldMap') as IPSDER1NDEFieldMap[];
    }
    return this.psder1ndefieldmaps;
  }

  get psDER1NDEFieldMaps(): IPSDER1NDEFieldMap[] | null {
    return this.getPSDER1NDEFieldMaps();
  }

  findPSDER1NDEFieldMap(objKey: any): IPSDER1NDEFieldMap | null {
    return this.getPSModel5('dataentity.der.IPSDER1NDEFieldMap', this.getPSDER1NDEFieldMaps(), objKey) as IPSDER1NDEFieldMap;
  }

  protected psone2manydatadefield: IPSOne2ManyDataDEField | null = null;

  getPSOne2ManyDataDEField(): IPSOne2ManyDataDEField | null {
    if (this.psone2manydatadefield != null) return this.psone2manydatadefield;
    const value = this.M.getPSOne2ManyDataDEField;
    if (value == null) {
      return null;
    }
    this.psone2manydatadefield = this.getPSModel4('dataentity.defield.IPSOne2ManyDataDEField', value, 'getPSOne2ManyDataDEField') as IPSOne2ManyDataDEField;
    return this.psone2manydatadefield;
  }

  get psOne2ManyDataDEField(): IPSOne2ManyDataDEField | null {
    return this.getPSOne2ManyDataDEField();
  }

  getPSOne2ManyDataDEFieldMust(): IPSOne2ManyDataDEField {
    const value = this.getPSOne2ManyDataDEField();
    if (value == null) {
      throw new Error('未指定一对多关系数据属性');
    }
    return value;
  }

  protected pspickupdefield: IPSPickupDEField | null = null;

  getPSPickupDEField(): IPSPickupDEField | null {
    if (this.pspickupdefield != null) return this.pspickupdefield;
    const value = this.M.getPSPickupDEField;
    if (value == null) {
      return null;
    }
    this.pspickupdefield = this.getPSModel4('dataentity.defield.IPSPickupDEField', value, 'getPSPickupDEField') as IPSPickupDEField;
    return this.pspickupdefield;
  }

  get psPickupDEField(): IPSPickupDEField | null {
    return this.getPSPickupDEField();
  }

  getPSPickupDEFieldMust(): IPSPickupDEField {
    const value = this.getPSPickupDEField();
    if (value == null) {
      throw new Error('未指定外键属性');
    }
    return value;
  }

  protected pspickuptextdefield: IPSLinkDEField | null = null;

  getPSPickupTextDEField(): IPSLinkDEField | null {
    if (this.pspickuptextdefield != null) return this.pspickuptextdefield;
    const value = this.M.getPSPickupTextDEField;
    if (value == null) {
      return null;
    }
    this.pspickuptextdefield = this.getPSModel4('dataentity.defield.IPSLinkDEField', value, 'getPSPickupTextDEField') as IPSLinkDEField;
    return this.pspickuptextdefield;
  }

  get psPickupTextDEField(): IPSLinkDEField | null {
    return this.getPSPickupTextDEField();
  }

  getPSPickupTextDEFieldMust(): IPSLinkDEField {
    const value = this.getPSPickupTextDEField();
    if (value == null) {
      throw new Error('未指定外键文本属性');
    }
    return value;
  }

  get pickupDEFName(): string {
    return this.M.pickupDEFName;
  }

  get rRMLanResTag(): string {
    return this.M.rRMLanResTag;
  }

  protected rrmpslanguageres: IPSLanguageRes | null = null;

  getRRMPSLanguageRes(): IPSLanguageRes | null {
    if (this.rrmpslanguageres != null) return this.rrmpslanguageres;
    const value = this.M.getRRMPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.rrmpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getRRMPSLanguageRes') as IPSLanguageRes;
    return this.rrmpslanguageres;
  }

  get rRMPSLanguageRes(): IPSLanguageRes | null {
    return this.getRRMPSLanguageRes();
  }

  getRRMPSLanguageResMust(): IPSLanguageRes {
    const value = this.getRRMPSLanguageRes();
    if (value == null) {
      throw new Error('未指定删除拒绝消息语言资源');
    }
    return value;
  }

  protected refpsdedataset: IPSDEDataSet | null = null;

  getRefPSDEDataSet(): IPSDEDataSet | null {
    if (this.refpsdedataset != null) return this.refpsdedataset;
    const value = this.M.getRefPSDEDataSet;
    if (value == null) {
      return null;
    }
    this.refpsdedataset = this.getMajorPSDataEntityMust().findPSDEDataSet(value);
    return this.refpsdedataset;
  }

  get refPSDEDataSet(): IPSDEDataSet | null {
    return this.getRefPSDEDataSet();
  }

  getRefPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getRefPSDEDataSet();
    if (value == null) {
      throw new Error('未指定引用实体数据集');
    }
    return value;
  }

  get removeActionType(): 0 | 1 | 2 | 3 {
    return this.M.removeActionType;
  }

  get removeOrder(): number {
    return this.M.removeOrder;
  }

  get removeRejectMsg(): string {
    return this.M.removeRejectMsg;
  }

  get syncDataMode(): 1 | 2 {
    return this.M.syncDataMode != null ? this.M.syncDataMode : 0;
  }

  get cloneRS(): boolean {
    return this.M.cloneRS != null ? this.M.cloneRS : false;
  }

  get enableDEFieldWriteBack(): boolean {
    return this.M.enableDEFieldWriteBack != null ? this.M.enableDEFieldWriteBack : false;
  }

  get enableExtRestrict(): boolean {
    return this.M.enableExtRestrict != null ? this.M.enableExtRestrict : false;
  }

  get enableFKey(): boolean {
    return this.M.enableFKey != null ? this.M.enableFKey : false;
  }

  get enablePDEREQ(): boolean {
    return this.M.enablePDEREQ != null ? this.M.enablePDEREQ : false;
  }

  get nestedRS(): boolean {
    return this.M.nestedRS != null ? this.M.nestedRS : false;
  }

  get recursiveRS(): boolean {
    return this.M.recursiveRS != null ? this.M.recursiveRS : false;
  }

  get cls(): string {
    return 'PSDER1NImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.der.IPSDER1N') return true;
    return super.instanceof(cls);
  }
}
